<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
</head>
<body>
  <script>
    // 准备一个待遍历的学生对象stu
    var stu = { 
      name: '小明',
      age: 18,
      sex: '男'
    };
    // 遍历学生对象stu
    for (var k in stu) {
      console.log(k + '---' + stu[k]);
    }
  </script>
</body>
</html>